/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package prak6;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Imung
 */
public class Main {
    public static void main(String[] args){
        appConnection conn = new appConnection("jdbc:mysql://localhost:3306/pbo");
        conn.dmlQuery("insert into mahasiswa values('nama 1','nim 1')");
        conn.dmlQuery("insert into mahasiswa values('nama 2','nim 2')");
        conn.dmlQuery("insert into mahasiswa values('nama 3','nim 3')");
        conn.dmlQuery("update mahasiswa set nim = 'nim 0' where nim = 'nim 1'");
        ResultSet rs =conn.query("select * from mahasiswa");
        show(rs);
        System.out.println("after delete");
        conn.dmlQuery("delete from mahasiswa where nim = 'nim 2'");
        rs = conn.query("select * from mahasiswa");
        show(rs);
        
    }
    
    private static void show(ResultSet rs){
        try{
            while (rs.next()){
                System.out.println(rs.getString(1)+ "||" + rs.getString(2));
            }
        }
        catch(SQLException ex) {}
    }
}
